<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
	<head> 
    <meta charset="UTF-8">
    <%@ include file="/WEB-INF/views/include/head.jsp"%>
    <link rel="stylesheet" href="${ctxStatic}/css/common_erp.css">
    <link rel="stylesheet" href="${ctxStatic}/css/layerSm.css"> 
    <script src="${ctxStatic}/dateCalendar/WdatePicker.js"></script>
    <script type="text/javascript">
    
    $(document).ready(function() {
    	var form = $("#inputForm");  
        form.validate();//验证指定的表单
        $("#confirmBtn").click(function(){
    		if (form.valid()) {//如果表单验证成功，则进行提交。  
    			saveForm.save($("#confirmBtn"))
          	}
     	});
    })
    
    //删除方法
    function delInventory(){
          // 调用后台删除方法
        $.post("${ctx}/inventory/warning/delete?materialId=${inventoryWarning.materialId}",'',function(result){
             // 提示信息
             tipParent(result.message);
             // 返回状态
            if(result.statusCode==STATUSCODEOK){
                 // 刷新页面
                window.parent.frames[0].searchListForm();
                 // 关闭页面
                closeWin(); 
             }
        },'json');
   }
    
  //保存方法
    var saveForm={
         t:null,
         save:function(t){
             $(t).attr("disabled",true);
             this.t=t;
             var alertFlag = $("#alertFlag").val();
             if (alertFlag != "无") {
            	 $("#alertFlag").val("update");
			 }else{
				 $("#alertFlag").val("insert");
			 }
          	// 格式化，去除逗号
             formUnFormat($("#inputForm"));
      	     var params = $("#inputForm").serialize();
             $.post("${ctx}/material/stock/saveInventoryAlert",params,function(result){
                 // 返回状态
                 if(result == "true"){
                    // 刷新页面
                    tipParent("保存成功");
                    window.parent.frames[0].searchListForm();
                    closeWin(); 
                 }else{
                	 tipParent("保存失败 ");
                     $(saveForm.t).attr("disabled",false);
                 }
             },'json');
         } 
    }
  
   </script>
   
    </head>
	<body>
	<!-- 创建页面head部 -->
	<div id="editPage" class="layerHeader clearfix">
    	<p class="headerTitle"><spring:message code="inventoryWarning"/></p>
			<div class="headerButton clearfix">
	        <shiro:hasPermission name="material:stock:edit">
            <!-- 删除 -->
            <button type="button" onclick="del(delInventory)"><spring:message code="btn_delete"/></button>
            <!-- 保存 -->
	        <button type="button" id="confirmBtn" onclick="">
	        <spring:message code="common_save"/> 
	        </button>
            </shiro:hasPermission>
            <!-- 取消 -->
            <button type="button" onclick="closeWin()"><spring:message code="btn_cancle"/></button>          
	    </div>
	</div>

<form id="inputForm" method="post" >

<div id="showHtml">
<input type="hidden" id="materialId" name="materialId" value="${inventoryWarning.materialId}"/>
<input type="hidden" id="factoryId" name="factoryId" value="${inventoryWarning.factoryId}"/>
<input type="hidden" id="alertFlag" name="alertFlag" value="${inventoryWarning.materialAlertQuantity}"/>
	<div class="smList">
			<div class="items clearfix">
	            <div class="col-50 clearfix">
	            	<!--物料编码-->
	                <p class="tit" style="width: 80px;">
	                	<spring:message code="inventoryWarning_materialcode"/>
	                </p>
	                <label>${inventoryWarning.materialCode}</label>
	            </div>
	        	<div class="col-50 right clearfix">
	        		<!--客户名称-->
	                <p class="tit" style="width: 80px;">
	                	<spring:message code="inventoryWarning_customerName"/>
	                </p>
	                <label>${inventoryWarning.customerName}</label>
	            </div>
	        </div>
	        <div class="items clearfix">
	            <div class="col-50 clearfix haveToBox">
	            	<!--预警数量：-->
	                <p class="tit" style="width: 80px;">
	                	<spring:message code="inventoryWarning_materialAlertQuantity"/>
	                </p>
	                 <input id="materialAlertQuantity" name="materialAlertQuantity"   value="${inWarning.materialAlertQuantity}"  data-rule-required="true" data-msg-required="<spring:message code="inventoryWarning_please_write_materialAlertQuantity"/>">
	                <p>&nbsp;${fns:getDictName(inventoryWarning.materialUnitCd) }</p>
	                <p class="haveTo">*</p>
	            </div>
	        	<div class="col-50 right clearfix">
	        		<!--最少采购数量：-->
	                <p class="tit" style="width: 80px;">
	                	<spring:message code="inventoryWarning_materialLeastQuantity"/>
	                </p>
	                <input id="materialLeastQuantity" name="materialLeastQuantity"   value="${inWarning.materialLeastQuantity}">
	           		<p>&nbsp;${fns:getDictName(inventoryWarning.materialUnitCd) }</p>
	            </div>
	        </div>
	        <div class="items clearfix">
	        	<div class="col-50 clearfix">
	        		<!--预警开始日期：-->
	                <p class="tit" style="width: 80px;">
	                	<spring:message code="inventoryWarning_materialAlertStartDate"/>
	                </p>
	                 <input id="materialAlertStartDate" name="materialAlertStartDate" class="laydate-icon" onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',onpicked:null})"  value="<fmt:formatDate value="${inWarning.materialAlertStartDate}" pattern="yyyy-MM-dd"/>">
	            </div>
	            <div class="col-50 right clearfix">
	            	<!--预警结束日期：-->
	                <p class="tit" style="width: 80px;">
	                	<spring:message code="inventoryWarning_materialAlertEndDate"/>
	                </p>
	                 <input id="materialAlertEndDate" name="materialAlertEndDate" class="laydate-icon" onclick="WdatePicker({el:this,dateFmt:'yyyy-MM-dd',onpicked:null})"  value="<fmt:formatDate value="${inWarning.materialAlertEndDate}" pattern="yyyy-MM-dd"/>">
	            </div>
	        </div>
	</div>
</div>
</form>
</body>
</html>
